#ifndef MYTCPSOCKET_H
#define MYTCPSOCKET_H

#include <QTcpSocket>

class MyTcpSocket : public QTcpSocket
{
    Q_OBJECT
public:
    explicit MyTcpSocket(QObject *parent = nullptr);
    bool setSocketDescriptor(qintptr socketDescriptor,QAbstractSocket::SocketState SocketState = ConnectedState,QIODevice::OpenMode openMode = ReadWrite);


protected slots:
    void readyReadSlot();


protected:
  void  handleFrame(const QByteArray &data);
// void  userCreate(const QJsonObject &obj);
 void userLogin(const QJsonObject &obj);
 //void userGetInfo();

void receiveMessage(const QJsonObject &obj);
void LoginFeedBack(const QJsonObject &obj);
//void  controlHighLightLED(const QJsonObject &obj);
//void controlRGBLED(const QJsonObject &obj);
void controlNormalDevice(const QJsonObject &obj);
void foundOldMessage(const QJsonObject &obj);
void searchTodayMessage(QString device_id);
void controlDevice(const QJsonObject &obj);
void userGetMyDeviceName(const QJsonObject &obj);

    QString ip;
    quint16 port;
    qintptr socketDes;
    int  clientType=-1;
    QString secretKey;
    QString userName;
    QString Name;
    bool isidentify=false;
    QList<int> groupList;
    int userId;
    QString deviceIndex;//记录index的
    QString deviceIdentification;//记录身份玛的


signals:

    void sendControlMessage(const QJsonObject &obj);


    void deviceControlToOne(QString index,const  QByteArray &data);//信号发给server


public slots:

    void sendControlMessageSlot(const QJsonObject &obj);

    void serverDeviceControlToOneSlot(QString index,const QByteArray &data);
};

#endif // MYTCPSOCKET_H
